package com.dshore.messagecenter.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class GetNowTimeListOFSeven {
	/** 获取对比时间集合(公共代码) */
	public List<String> getKpiTimes() {
		SimpleDateFormat df = new SimpleDateFormat("HH:mm");
		List<String> kpiTimes = new ArrayList<>();
		for(int i=6; i>=0; i--) {
			Calendar calendar = Calendar.getInstance();
			calendar.add(calendar.MINUTE, -(5 * i));
			int hour = calendar.get(Calendar.HOUR_OF_DAY);
			int minute = (calendar.get(Calendar.MINUTE) / 5) * 5;
			
			//转换格式
			df.applyPattern("HH:mm");
			Date date = null;
			try {
				date = df.parse(hour + ":" + minute);
			} catch (ParseException e) {
				e.printStackTrace();
			}
			//将秒钟转为HH:mm格式(防止秒钟为单数)
			String oneTime = df.format(date);
			
			kpiTimes.add(oneTime);
		}
		return kpiTimes;
	}
}
